/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.universityUnits;

import model.Collection;
import model.Constants;
import model.SimpleCollection;
import model.entitys.Named;

/**
 *
 * @author Slayer
 */
public class University extends Named implements UniversityInterface{
    private Collection<Faculty> faculties;
    private Collection<Event> events;

    public University(String name) {
        super(name);
        faculties = new SimpleCollection<Faculty>();
        events = new SimpleCollection<Event>();
    }
    
    public Faculty getFaculty(String name) {
        for (Object obj : faculties.toArray()) {
            Faculty faculty = (Faculty) obj;
            
            if (faculty.getName().equals(name)) {
                return faculty;
            }
        }
        
        return null;
    }
    
    public void add(Faculty faculty) {
        faculties.add(faculty);
    }
    
    public void add(Event event) {
        events.add(event);
    }
    
    public String printFaculties() {
        final StringBuilder builder = new StringBuilder();
        
        for (Object obj : faculties.toArray()) {
            Faculty faculty = (Faculty) obj;
            
            builder.append(faculty.toString());
            builder.append(Constants.LINE_SEPARATOR);
        }
        
        return builder.toString();
    }
    
    public String printEvents() {
        final StringBuilder builder = new StringBuilder();
        
        for (Object obj : events.toArray()) {
            Event event = (Event) obj;
            
            builder.append(event.toString());
            builder.append(Constants.LINE_SEPARATOR);
        }
        
        return builder.toString();
    }
}
